<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<!DOCTYPE html>
<html>
 <head>
  <title>服务商产能</title>
  <t:base type="jquery,easyui,tools,DatePicker"></t:base>
  <script type="text/javascript" src="plug-in/ckfinder/ckfinder.js"></script>
  <style type="text/css">
  	.value{
  		text-align: center;
  	}
  	.value input{
  		text-align: center;
  	}
  </style>
 </head>
 <body>
	<t:formvalid formid="formobj" dialog="true" usePlugin="password" layout="table" action="cbsServiceCapacityController.do?doUpdate" tiptype="1" showAllError="false" beforeSubmit="validNum">
	
		<table style="margin: 10px; width: 98%; margin: 0px auto;">
			<tr>
				<td>
					服务商：
					<select dataType="*" nullmsg="请选择服务商" name="serviceProvider" disabled="disabled">
						<option value="">--请选择--</option>
						<c:forEach items="${thirdDepartList }" var="depart">
							<option value="${depart.id }" <c:if test="${depart.id eq serviceProvider }">selected="selected"</c:if>>${depart.shortname }</option>
						</c:forEach>
					</select>
				</td>
				<td>
					年份
					<input type="text" name="year" id="year" value="${year }" disabled="disabled" onfocus="WdatePicker({isShowClear:false,ychanging:loadYear(),skin:'whyGreen',dateFmt:'yyyy'})" class="Wdate"/>
				</td>
			</tr>
		</table>
		<table style="width: 98%;margin: 0px auto;" cellpadding="0" cellspacing="1" class="formtable">
			<tr style="font-weight: bold; height: 40px; text-align: center;">
				<td>月份</td>
				<td>最低产能</td>
				<td>计划产能</td>
				<td>客户可调节最大产能</td>
			</tr>
			
			
			
			<c:forEach items="${dataList }" var="data" varStatus="a">
				<tr>
					<td class="value">
						<span class="year_text"></span> -
						<c:choose>
							<c:when test="${a.count < 10 }">0${a.count }</c:when>
							<c:otherwise>${a.count }</c:otherwise>
						</c:choose>
					</td>
					<input type="hidden" name="capacityIdStr" value="${data.id }">
					<td class="value">
						<input type="text" name="minCapacityStr" value="${data.minCapacity }" dataType="n" nullmsg="请输入一个整数" errormsg="请输入一个整数">
					</td>
					<td class="value">
						<input type="text" name="planCapacityStr" value="${data.planCapacity }" dataType="n" nullmsg="请输入一个整数" errormsg="请输入一个整数">
					</td>
					<td class="value">
						<input type="text" name="maxCapacityStr" value="${data.maxCapacity }" 
						ajaxurl="cbsServiceCapacityController.do?getServiceProviderIpEsNum&serviceId=${serviceProvider }&year=${year }&month=${a.count}" dataType="n" nullmsg="请输入一个整数" errormsg="请输入一个整数">
					</td>
				</tr>
			</c:forEach>
		</table>
	</t:formvalid>
 </body>
<script type="text/javascript">
	$(function(){
		loadYear();
	});
	
	function loadYear(){
		var year = $('#year').val();
		if(year != ''){
			$('.year_text').text(year);
		}
	}
	
	//数字验证   最小产能  < 计划产能 < 最大产能
	function validNum(){
		var flag = true;
		$('input[name="minCapacityStr"]').each(function(index,value){
			var plan = $('input[name="planCapacityStr"]:eq('+index+')').val();
			var max = $('input[name="maxCapacityStr"]:eq('+index+')').val();
			var min = $(this).val();
			plan = Number(plan);
			max = Number(max);
			min = Number(min);
			if(max < plan || plan < min){
				$.messager.alert('提示','您填写的'+(index+1)+'月份数据格式不正确</br>(例：最低产能 ≤ 计划产能 ≤ 客户可调节最大产能)');
				flag = false;
				return false
			}
		});
		return flag;
	}
</script>	